<?php if (!defined('THINK_PATH')) exit(); /*a:5:{s:65:"/home/xlosycom/public_html/application/admin/view/admin/film.html";i:1523884180;s:45:"./application/index/view/index/head_meta.html";i:1523930539;s:45:"./application/index/view/index/head_link.html";i:1523885480;s:47:"./application/index/view/index/head_script.html";i:1523888906;s:69:"/home/xlosycom/public_html/application/admin/view/admin/navigate.html";i:1523897880;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="<?php echo BASE_PATH; ?>">
    <title>影片添加</title>
    <!--引入头部meta文件 -->
    <meta name="pragma" content="no-cache">
<meta name="cache-control" content="no-cache">
<meta name="expires" content="0">
<meta name="keywords" content="<?php echo \think\Config::get('keywords'); ?>">
<meta name="description" content="<?php echo \think\Config::get('description'); ?>">
<meta http-equiv="Content-Type" content="<?php echo \think\Config::get('Content_Type'); ?>" />
<meta name="robots" content="<?php echo \think\Config::get('robots'); ?>">
<meta name="windows-Target" content="<?php echo \think\Config::get('windows_Target'); ?>">
<meta name="author" content="<?php echo \think\Config::get('author'); ?>">
<meta http-equiv="Content-Language" content="<?php echo \think\Config::get('content_language'); ?>"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!--引入头部link(css)文件 -->
    <link rel="shortcut icon" href="<?php echo \think\Config::get('page_icon'); ?>">
<link rel="stylesheet" href="public/static/css/base.css?v=<?php echo NOW_TIME; ?>"/>
<link rel="stylesheet" href="public/static/plugs/topNav/css/head.css?v=<?php echo NOW_TIME; ?>" />
<link rel="stylesheet" type="text/css" href="public/static/plugs/bootstrap3.3.7/css/bootstrap.css?v=<?php echo NOW_TIME; ?>">
    <!--引入头部script文件 -->
    <script src="public/static/js/jquery-2.0.0.min.js" type="text/javascript" charset="UTF-8" ></script>
<script src="public/static/js/base/base.js" type="text/javascript" charset="UTF-8" ></script>
<script src="public/static/plugs/bootstrap3.3.7/js/bootstrap.js" type="text/javascript" charset="UTF-8" ></script>
<script type="text/javascript" src="public/static/js/jquery.lazyload.min.js"></script>
<!--IE8只能支持jQuery1.9-->
<!--[if lte IE 8]>
<script src="http://cdn.bootcss.com/jquery/1.9.0/jquery.min.js"></script>
<!-->

    <link rel="stylesheet" href="public/static/plugs/uploadifyphp/uploadify.css" type="text/css">
    <link rel="stylesheet" href="public/static/css/admin/film.css?v=<?php echo NOW_TIME; ?>" type="text/css">
    <!--=====================JS_Link===========================-->
    <script type="text/javascript" src="public/static/plugs/uploadifyphp/jquery.uploadify.js"></script>

    <!--导航-->
    <script>
        $(function () {
            $(".nav-title").click(function () {
                $(this).parent().find(".nav2-ul").toggle();
                if ($(this).find(".nav-icon").css("background-position") == "-144px -27px") {
                    $(this).find(".nav-icon").css("background-position", "-92px -27px");
                } else {
                    $(this).find(".nav-icon").css("background-position", "-144px -27px");
                }
            });
        })
        /**
         * 设置模板类型
         */
        function setMoban() {
            $("#res_name").val("xxxx@@集##1##集数结束##分割符号");
        }
    </script>
    <!--导航-->
    <script>
        $(function () {

            /**
             *
             * 编辑取消按钮
             */
            $(".edit").click(function () {
                $(this).parent().parent().find(".label-input").show();
                $(this).parent().parent().find(".label").hide();
                var t = $(this).attr("t");
                if (t != undefined) {
                    $("#cancel-bt").hide();
                    $("#save-bt").hide();
                }
            })
            $(".cancel").click(function () {
                $(this).parent().parent().find(".label-input").hide();
                $(this).parent().parent().find(".label").show();

                var t = $(this).attr("t");
                if (t != undefined) {
                    var filepath = $(this).parent().parent().find(".label .update-pre div img").attr("src");

                    $.ajax({
                        type: "post",
                        url: "<?php echo url('admin/delFile'); ?>",
                        cache: false,
                        data: "picsPath=" + filepath,
                        dataType: 'json',     //接受数据格式
                        success: function (rs) {
                            var data = rs;
                            if (data.code == "1") {
                                $("#file_upload").show();
                                $(this).parent().parent().find(".label .update-pre div").remove();
                            } else {
                                alert("删除失败!");
                            }
                        },
                        error: function () {
                            alert("系统繁忙!");
                        }
                    });
                }

            })

            $(".save").click(function () {
                debugger;
                var key = $(this).parent().find(".update-input").attr("name");
                var key1 = "";
                var val = "";
                var val1 = "";
                var input = $(this).parent().find(".update-input");
                if (input.attr("el") == "div") {
                    val = input.val();
                } else {
                    if (key == "locName" || key == "typeName" || key =="isVip") {
                        val = input.val();
                        if(key !="isVip"){
                            val = input.find("option:selected").text();
                            key1 = input.attr("name1");
                            val1 = input.val();
                        }
                    } else if (key == "image") {
                        val = input.attr("src");
                    } else {
                        val = input.val();
                    }
                }
                var film_id = $(this).attr("film_id");
                if (val != undefined && val != "") {
                    updateFilmInfo(film_id, key, val, this);
                    if (key1 != "") {
                        setTimeout(function () {
                            updateFilmInfo(film_id, key1, val1, this);
                        }, 3000);
                    }
                } else {
                    alert("信息不完整");
                }
            })

            function updateFilmInfo(f_id, key, val, t) {
                $.ajax({
                    url: "<?php echo url('admin/updateFilmInfo'); ?>",
                    type: "post",
                    dataType: "json",
                    data: "film_id=" + f_id + "&key=" + key + "&val=" + val,
                    success: function (data) {
                        if (data == "1") {
                            $(t).parent().parent().find(".label-input").hide();
                            if (key == "image") {
                                $(t).parent().parent().find(".label").show().find("div img").attr("src", val);
                                $("#file_upload").show();
                                $(".file-pre div").remove();
                            } else {
                                if (key != "loc_id" && key != "type_id") {
                                    if(key=="isVip"){
                                        if(val=="1"){
                                            val = "是";
                                        }else{
                                            val = "否";
                                        }
                                    }
                                    $(t).parent().parent().find(".label").show().find(".show").text(val);
                                }
                            }
                        } else {
                            alert("更改失败");
                        }
                    },
                    error: function () {
                        alert("系统繁忙!");
                    }
                })
            }
        })
    </script>
</head>
<body>

<!--内容 START-->
<div class="box">
    <div class="box-left">
        <!--引入导航html文件 -->
        <!--导航-->
<ul class="nav1-ul">
    <li class="nav1-li">
        <h4 class="nav-title"><i class="nav-icon">&nbsp;</i>影片管理</h4>
        <ul class="nav2-ul">
            <a href="<?php echo url('admin/film'); ?>">
                <li class="nav2-li">添加影片</li>
            </a>
            <a href="<?php echo url('admin/film_list'); ?>">
                <li class="nav2-li">所有影片</li>
            </a>
        </ul>
    </li>
    <li class="nav1-li">
        <h4 class="nav-title"><i class="nav-icon">&nbsp;</i>目录管理</h4>
        <ul class="nav2-ul">
            <a href="<?php echo url('admin/catalogs'); ?>">
                <li class="nav2-li">添加目录</li>
            </a>
            <a href="<?php echo url('admin/vip_manager'); ?>">
                <li class="nav2-li">VIP管理</li>
            </a>
        </ul>
    </li>
</ul>
<!--导航-->
    </div>
    <div class="box-right">
        <div style="width:100%; height: auto;overflow:hidden;margin: 0px auto;">
            <ul class="film-info">
                <li class="title">
                    <div class="left-con">添加影片</div>
                    <div class="right-con"></div>
                </li>
                <li>
                    <div class="left-con">片名:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['name']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <input class="input update-input" placeholder="请填写影片名称" autocomplete="off" el="div"
                                           name="name" value="<?php echo $film['name']; ?>"/>
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <input class="input addFilmInput"  id="name" placeholder="请填写影片名称" autocomplete="off" value="<?php echo $film['name']; ?>"/>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">海报:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <div class="update-pre">
                                        <div><img src="<?php echo str_replace('static/upload','public/static/upload',$film['image']); ?>"/></div>
                                    </div>
                                    <a href="javascript:;" class="btn edit" t="img">编辑</a>
                                </div>
                                <div class="label-input">
                                    <input id="file_upload" name="file_upload" type="file">
                                    <div class="file-pre"></div>
                                    <a href="javascript:;" class="btn save" id="save-bt" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel" t="img" id="cancel-bt">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <input id="file_upload" name="file_upload" type="file">
                            <div class="file-pre"></div>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">上映年代:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['onDecade']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <select class="input fixSelect update-input" el="select" name="onDecade">
                                        <?php if(is_array($decadeList) || $decadeList instanceof \think\Collection || $decadeList instanceof \think\Paginator): $i = 0; $__LIST__ = $decadeList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$decadeList_list): $mod = ($i % 2 );++$i;?>
                                            <option value="<?php echo $decadeList_list['name']; ?>"><?php echo $decadeList_list['name']; ?></option>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                    <!-- <div class="input update-input" contenteditable="true" name="name"><?php echo $film['name']; ?></div>-->
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <select id="onDecade" class="input fixSelect">
                                <?php if(is_array($decadeList) || $decadeList instanceof \think\Collection || $decadeList instanceof \think\Paginator): $i = 0; $__LIST__ = $decadeList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$decadeList_list): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $decadeList_list['name']; ?>"><?php echo $decadeList_list['name']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select><span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">状态:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['status']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <input class="input update-input" placeholder="全集/更新第几集" autocomplete="off" el="div"
                                           name="status" value="<?php echo $film['status']; ?>"/>
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <input class="input addFilmInput" placeholder="全集/更新第几集" autocomplete="off" value="全集" id="status"/>
                            <span style="color:red;">*</span>
                        <?php endif; ?>

                    </div>
                </li>
                <li>
                    <div class="left-con">分辨率:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['resolution']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <select name="resolution" class="input fixSelect update-input" el="select">
                                        <option value="1080">1080p</option>
                                        <option value="720">720p</option>
                                        <option value="480">480p</option>
                                    </select>

                                    <!-- <div class="input update-input" contenteditable="true" name="name"><?php echo $film['name']; ?></div>-->
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <select id="resolution" class="input fixSelect">
                                <option value="1080">1080p</option>
                                <option value="720">720p</option>
                                <option value="480">480p</option>
                            </select>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">类型:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['typeName']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <select class="cataLog_id_subClass input fixSelect">
                                        <?php if(is_array($cataLogList) || $cataLogList instanceof \think\Collection || $cataLogList instanceof \think\Paginator): $i = 0; $__LIST__ = $cataLogList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cataLogList_var): $mod = ($i % 2 );++$i;?>
                                            <option value="<?php echo $cataLogList_var['id']; ?>"><?php echo $cataLogList_var['name']; ?></option>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>&nbsp;
                                    <select class="subClass_id input fixSelect"></select>&nbsp;
                                    <select name="typeName" name1="type_id" class="type_id input fixSelect update-input"
                                            id="type_id" el="select"></select>

                                    <!-- <div class="input update-input" contenteditable="true" name="name"><?php echo $film['name']; ?></div>-->
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <select class="cataLog_id_subClass input fixSelect">
                                <?php if(is_array($cataLogList) || $cataLogList instanceof \think\Collection || $cataLogList instanceof \think\Paginator): $i = 0; $__LIST__ = $cataLogList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$cataLogList_var): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $cataLogList_var['id']; ?>"><?php echo $cataLogList_var['name']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>&nbsp;
                            <select class="subClass_id input fixSelect"></select>&nbsp;
                            <select class="type_id input fixSelect" id="type_id"></select>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">演员:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['actor']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <input class="input  update-input" placeholder="请填写演员名称，多个演员请用逗号隔开"  autocomplete="off" el="div"
                                           name="actor" value="<?php echo $film['actor']; ?>"/>
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <input class="input  addFilmInput" placeholder="请填写演员名称，多个演员请用逗号隔开" value="平民" autocomplete="off" id="actor"/>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">地区:</div>
                    <div class="right-con">

                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['locName']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <select name="locName" name1="loc_id" class="input fixSelect update-input"
                                            el="select">
                                        <?php if(is_array($locList) || $locList instanceof \think\Collection || $locList instanceof \think\Paginator): $i = 0; $__LIST__ = $locList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$locList_list): $mod = ($i % 2 );++$i;?>
                                            <option value="<?php echo $locList_list['id']; ?>"><?php echo $locList_list['name']; ?></option>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                    <!-- <div class="input update-input" contenteditable="true" name="name"><?php echo $film['name']; ?></div>-->
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <select id="locName" class="input fixSelect">
                                <?php if(is_array($locList) || $locList instanceof \think\Collection || $locList instanceof \think\Paginator): $i = 0; $__LIST__ = $locList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$locList_list): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $locList_list['id']; ?>"><?php echo $locList_list['name']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">剧情:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                            <div class="update">
                                <div class="label">
                                    <a class="show" href="javascript:;"><?php echo $film['plot']; ?></a>
                                    <a href="javascript:;" class="btn edit">编辑</a>
                                </div>
                                <div class="label-input">
                                    <textarea class="input contentType update-input" placeholder="请简短填写剧情介绍" autocomplete="off" el="div"
                                              name="plot"><?php echo $film['plot']; ?></textarea>
                                    <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                    <a href="javascript:;" class="btn cancel">取消</a>
                                </div>
                            </div>
                        <?php endif; if($film==null): ?>
                            <textarea class="input contentType addFilmInput" placeholder="请简短填写剧情介绍" autocomplete="off" id="plot"></textarea>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con">是否vip:</div>
                    <div class="right-con">
                        <?php if($film!=null): ?>
                        <div class="update">
                            <div class="label">
                                <a class="show" href="javascript:;">
                                    <?php if($film['isVip']=='1'): ?>
                                        是
                                    <?php else: ?>
                                        否
                                    <?php endif; ?>
                                </a>
                                <a href="javascript:;" class="btn edit">编辑</a>
                            </div>
                            <div class="label-input">
                                <select name="isVip"  id="isVip"  class="input fixSelect update-input" el="select">
                                    <?php if($film['isVip']=='1'): ?>
                                        <option value="">请选择</option>
                                        <option value="1" selected>是</option>
                                        <option value="0">否</option>
                                    <?php else: ?>
                                        <option value="">请选择</option>
                                        <option value="1">是</option>
                                        <option value="0" selected>否</option>
                                    <?php endif; ?>
                                </select>
                                <a href="javascript:;" class="btn save" film_id="<?php echo $film['id']; ?>">保存</a>
                                <a href="javascript:;" class="btn cancel">取消</a>
                            </div>
                        </div>
                        <?php endif; if($film==null): ?>
                            <select name="isVip"  id="isVip" class="input fixSelect update-input" el="select">
                                <option value="">请选择</option>
                                <option value="1">是</option>
                                <option value="0">否</option>
                            </select>
                            <span style="color:red;">*</span>
                        <?php endif; ?>
                    </div>
                </li>
                <li>
                    <div class="left-con"></div>
                    <div class="right-con">
                        <?php if($film==null): ?>
                            <a href="javascript:;" class="btn" id="addFilm-btn">添加影片</a>
                            <a href="javascript:;" class="btn" onclick="clearAddFilmInput()">清空</a>
                        <?php endif; ?>
                    </div>
                </li>

                <?php if($film!=null): ?>
                    <li class="title">
                        <div class="left-con">影片资源</div>
                        <div class="right-con"><span class="zhuti"></span></div>
                    </li>
                    <?php if($res==null): ?>
                        <li>
                            <div style="width: auto;height: auto;margin: 20px auto;text-align: center;font-size: 12px;font-family: '微软雅黑';">
                                暂无资源
                            </div>
                        </li>
                    <?php endif; endif; if(is_array($res) || $res instanceof \think\Collection || $res instanceof \think\Paginator): $i = 0; $__LIST__ = $res;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$res_list): $mod = ($i % 2 );++$i;?>
                    <li>
                        <ul class="zi_yuan_list">
                            <li><a href="<?php echo $res_list['link']; ?>" class="show" title="<?php echo $res_list['name']; ?>"><?php echo $res_list['name']; ?></a>
                            </li>
                            <li>
                                <a href="javascript:;" class="show"><?php echo $res_list['linkType']; ?></a>
                            </li>
                            <li><a href="javascript:;" class="show isUse">
                                <?php if($res_list['isUse']==1): ?>
                                    在线
                                <?php endif; if($res_list['isUse']==0): ?>
                                    离线
                                <?php endif; ?>
                            </a></li>
                            <li><a href="javascript:;" class="show"><?php echo $res_list['updateTime']; ?></a></li>
                            <li>
                                <?php if($res_list['isUse']==1): ?>
                                    <a href="javascript:;" class="btn updateIsUse" res_id="<?php echo $res_list['id']; ?>">离线</a>
                                <?php endif; if($res_list['isUse']==0): ?>
                                    <a href="javascript:;" class="btn updateIsUse" res_id="<?php echo $res_list['id']; ?>">在线</a>
                                <?php endif; ?>
                                <a href="javascript:;" class="btn delRes" res_id="<?php echo $res_list['id']; ?>">删除</a>
                            </li>
                        </ul>
                    </li>
                <?php endforeach; endif; else: echo "" ;endif; ?>
                <li class="title">
                    <div class="left-con">添加资源</div>
                    <div class="right-con"><span class="zhuti">
                <?php if($film!=null): ?>
                    <a href="javascript:;" class="show">影片主体：<?php echo $film['id']; ?></a>
                <?php endif; ?>
                </span></div>
                </li>
                <li>
                    <div class="left-con">资源名:</div>
                    <div class="right-con">
                        <input class="input longInput addResInput" placeholder="请填写资源名" autocomplete="off" value="<?php echo $film['name']; ?>" id="res_name"/>
                        <span style="color:red;">*</span><span style="color:#ddd;">(若百度资源请将密码填在此处，无需填写名称)</span><a href="javascript:;"  class="btn" onclick="setMoban()">多资源模板</a></div>
                </li>

                <li>
                    <div class="left-con">当前集数:</div>
                    <div class="right-con">
                        <select class="input fixSelect" id="res_episodes">
                            <?php $__FOR_START_501407712__=1;$__FOR_END_501407712__=100;for($i=$__FOR_START_501407712__;$i < $__FOR_END_501407712__;$i+=1){ ?>
                                <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                            <?php } ?>
                        </select>
                        <span style="color:red;">*</span>
                    </div>
                </li>

                <li>
                    <div class="left-con">链接:</div>
                    <div class="right-con">
                        <textarea class="input contentType addResInput" placeholder="请填写资源链接，并在下个选择栏选择正确的资源类型" autocomplete="off" id="res_link"></textarea>
                        <span style="color:red;">*</span></div>
                </li>

                <li>
                    <div class="left-con">链接类型:</div>
                    <div class="right-con">
                        <select class="input fixSelect" id="res_linkType">
                            <option value="Flh">Flash</option>
                            <option value="ed2k">电驴</option>
                            <option value="thunder">迅雷</option>
                            <option value="http">离线</option>
                            <option value="dupan">度盘</option>
                            <option value="other">其它</option>
                        </select>
                        <span style="color:red;">*</span>
                    </div>
                </li>

                <li>
                    <div class="left-con"></div>
                    <div class="right-con">
                        <a href="javascript:;" class="btn" id="addRes-btn">
                            添加资源+</a>
                        <a href="javascript:;" class="btn" onclick="clearAddResInput()">清空</a>
                        <a href="javascript:;" class="alert-box">温馨提示：清空后可继续添加更多资源</a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
<!--内容 END-->


<script>
    $(function () {

        /**
         * 同步更改二级目录
         */
        $(".cataLog_id_subClass").change(function () {
            var catalog_id = $(this).val();
            $.ajax({
                url: "<?php echo url('admin/getSubClass'); ?>",
                type: "post",
                dataType: "json",
                data: "catalog_id=" + catalog_id,
                success: function (data) {
                    $(".subClass_id").find("option").remove();
                    var jss = data;
                    for (var i = 0; i < jss.length; i++) {
                        var op = "<option value='" + jss[i].id + "'>" + jss[i].name + "</option>";
                        $(".subClass_id").append($(op));
                    }
                    getType();
                },
                error: function () {
                    alert("系统繁忙!");
                }
            });
        });

        /**
         * 同步更改type类型
         */
        $(".subClass_id").change(function () {
            getType();
        });

        /**
         * 初始目录
         */
        $.ajax({
            url: "<?php echo url('admin/getSubClass'); ?>",
            type: "POST",
            dataType: "json",
            data: "catalog_id=" + $(".cataLog_id_subClass").val(),
            success: function (data) {
                var jss = data;
                for (var i = 0; i < jss.length; i++) {
                    var op1 = "<option value='" + jss[i].id + "'>" + jss[i].name + "</option>";
                    $(".subClass_id").append($(op1));
                }
                getType();
            },
            error: function () {
                alert("系统繁忙!");
            }
        });

        $("#addRes-btn").attr("film_id","<?php echo $film['id']; ?>");

        /**
         * 获取类型
         */
        function getType() {
            $.ajax({
                url: "<?php echo url('admin/getType'); ?>",
                type: "POST",
                dataType: "json",
                data: "subClass_id=" + $(".subClass_id").val(),
                success: function (data) {
                    $(".type_id").find("option").remove();
                    var jss = data;
                    for (var i = 0; i < jss.length; i++) {
                        var op1 = "<option value='" + jss[i].id + "'>" + jss[i].name + "</option>";
                        $(".type_id").append($(op1));
                    }
                },
                error: function () {
                    alert("系统繁忙!");
                }
            });
        }


        /**
         * 添加film
         */
        $("#addFilm-btn").click(function () {
            var name_val = $("#name").val();
            var image_val = $("#image").attr("src");
            var onDecade_val = $("#onDecade").val();
            var status_val = $("#status").val();
            var resolution_val = $("#resolution").val();
            var typeName_val = $("#type_id").find("option:selected").text();
            var type_id_val = $("#type_id").val();
            var actor_val = $("#actor").val();
            var locName_val = $("#locName").find("option:selected").text();
            var loc_id_val = $("#locName").val();
            var plot_val = $("#plot").val();
            var is_vip = $("#isVip").val();
            if (name_val == ""
                || image_val == ""
                || image_val == undefined
                || onDecade_val == ""
                || status_val == ""
                || resolution_val == ""
                || typeName_val == ""
                || type_id_val == ""
                || actor_val == ""
                || locName_val == ""
                || loc_id_val == ""
                || plot_val == ""
                || is_vip == ""
            ) {
                if (name_val == "") {
                    alert("片名为空");
                } else if (image_val == "") {
                    alert("海报为空");
                } else if (onDecade_val == "") {
                    alert("年代为空");
                } else if (status_val == "") {
                    alert("状态为空");
                } else if (resolution_val == "") {
                    alert("分辨率为空");
                } else if (typeName_val == "") {
                    alert("类型名称为空");
                } else if (type_id_val == "") {
                    alert("类型编码为空");
                } else if (actor_val == "") {
                    alert("演员为空");
                } else if (locName_val == "") {
                    alert("地区名为空");
                } else if (loc_id_val == "") {
                    alert("地区编码为空");
                } else if (plot_val == "") {
                    alert("剧情为空");
                } else if (image_val == undefined) {
                    alert("海报为空");
                }else if (is_vip == undefined) {
                    alert("请选择是否为VIP");
                }
            } else if($("#addRes-btn").attr("film_id")=='' || $("#addRes-btn").attr("film_id")==undefined){
                //添加影片
                $.ajax({
                    url: "<?php echo url('admin/addFilm'); ?>",
                    type: "post",
                    dataType: "json",
                    data: "name=" + name_val +
                    "&image=" + image_val +
                    "&onDecade=" + onDecade_val +
                    "&status=" + status_val +
                    "&resolution=" + resolution_val +
                    "&typeName=" + typeName_val +
                    "&type_id=" + type_id_val +
                    "&actor=" + actor_val +
                    "&locName=" + locName_val +
                    "&loc_id=" + loc_id_val +
                    "&plot=" + plot_val+
                    "&isVip=" + is_vip,
                    success: addSuccess,
                    error: function () {
                        alert("系统繁忙！");
                    }
                });
            }
        });

        /**
         * 添加影片资源
         */
        $("#addRes-btn").click(function () {
            var film_id = $(this).attr("film_id");
            var res_name_val = $("#res_name").val();
            var res_episodes_val = $("#res_episodes").val();
            var res_link_val = $("#res_link").val();
            var res_linkType_val = $("#res_linkType").val();
            if (film_id == undefined || film_id === "") {
                alert("没有影片主体");
            } else if (res_name_val == ""
                || res_episodes_val == ""
                || res_link_val == ""
                || res_linkType_val == ""
            ) {
                alert("信息未填写完整，请检查");
            } else {
                $.ajax({
                    url: "<?php echo url('admin/addRes'); ?>",
                    type: "POST",
                    dataType: "json",
                    data: "film_id=" + film_id +
                    "&name=" + res_name_val +
                    "&episodes=" + res_episodes_val +
                    "&link=" + res_link_val +
                    "&linkType=" + res_linkType_val
                    ,
                    success: function (data) {
                        if (data != "0") {
                            alert("添加成功");
                            var film = "<?php echo $film['id']; ?>";
                            if (film != "") {
                                location.reload();
                            }
                        } else {
                            alert("添加失败");
                        }
                    },
                    error: function () {
                        alert("系统繁忙!");
                    }
                });
            }
        });


        /**
         * 添加影片成功
         */
        function addSuccess(data) {

            if (data != "0") {
                $("#addRes-btn").attr("film_id", data);
                $(".zhuti").text("影片主体：" + data);
                alert("添加影片成功");
                var path  = "<?php echo url('admin/film'); ?>";
                var presuffix = path.substr(0,path.length-5);
                var url = presuffix+"/film_id/"+data;
                location.href = url;
            } else {
                alert("添加影片失败");
            }
        }

        /**
         * 更改资源在线离线状态
         */
        $(".updateIsUse").click(function () {
            var resId = $(this).attr("res_id");
            if(resId==""){
                alert("更改的对象为空!");
                return;
            }
            $.ajax({
                url: "<?php echo url('admin/updateIsUse'); ?>",
                type: "post",
                dataType: "json",
                data: "res_id=" + resId,
                success: function (data) {
                    if ("1" == data) {
                        alert("修改成功");
                        location.reload();
                    } else {
                        alert("修改失败");
                    }
                }
            });
        })

        /**
         * 删除资源
         */
        $(".delRes").click(function () {

            var resId = $(this).attr("res_id");
            if(resId==''){
                alert("删除对象为空!");
                return;
            }
            var isEnsure = confirm("确定删除?");
            if (isEnsure) {
                $.ajax({
                    url: "<?php echo url('admin/delRes'); ?>",
                    type: "post",
                    dataType: "json",
                    data: "res_id=" + resId,
                    success: function (data) {
                        if (data == "1") {
                            alert("删除成功");
                            location.reload();
                        }
                    },
                    error: function () {
                        alert("删除失败!");
                    }
                });
            }
        })

    })

    /**
     *
     * 清空资源表单
     */
    function clearAddResInput() {
        $(".addResInput").val("");
    }


    /**
     *
     * 清空影片表单
     */
    function clearAddFilmInput() {
        $(".addFilmInput").val("");
    }

    /**
     * 文件上传
     */
    var timestamp = new Date().getTime();
    $(function() {
        $("#file_upload").uploadify({
            'formData': {
                'timestamp': timestamp,
                'childPath': 'filmPic',
                'token': 'unique_salt' + timestamp
            },// 设置想后台传递的参数 如果设置该参数，那么method应该设置为get，才能得到参数
            "width": 120,
            "height": 30,
            "swf": "public/static/plugs/uploadify/uploadify.swf",
            "fileObjName": "download",
            "buttonText": "上传海报",
            "uploader": "<?php echo url('admin/upload'); ?>",
            'cancelImg': 'public/static/plugs/uploadify/uploadify-cancel.png',// 取消按钮图片路径
            'removeTimeout': 1,
            'method': 'post',
            'fileTypeExts': '*',
            'simUploadLimit': 1,
            'auto': true,// 当选中文件后是否自动提交
            'uploadLimit': 0,
            'multi': false,//支持多文件上传
            "onUploadSuccess": uploadFinish,
            'onFallback': function () {
                alert('未检测到兼容版本的Flash.');
            }
        });
    });



    function uploadFinish(file, data) {
        var file_info = JSON.parse(data).filePath;
        $(".file-pre").append($("<div><img src='" + file_info + "' class='update-input' id='image' el='img' name='image'/><a onClick='del(this)' class='del'>删除</a></div>"));
        setTimeout(function () {
            $("#cancel-bt").show();
            $("#save-bt").show();
            $("#file_upload").hide();
        }, 1000);
    }


    /**删除图片*/
    function del(e) {
        if (confirm("确定删除吗")) {

            $.ajax({
                type: "post",
                url: "<?php echo url('admin/delete_file'); ?>",
                cache: false,
                data: "picsPath=" + $(e).parent("div").find("img").attr("src"),
                dataType: 'json',     //接受数据格式
                success: function (rs) {
                    var data = rs;
                    if (data.code == "1") {
                        $(e).parent("div").remove();
                        $("#file_upload").show();
                    } else {
                        alert("删除失败!");
                    }
                },
                error: function () {
                    alert("系统繁忙!");
                }
            });
        }
    }
</script>
</body>
</html>